import './style.less';
require('purecss');
require('font-awesome/css/font-awesome.min.css');

// 拉取
// 保存
const save = document.getElementById('save');
let headers = new Headers();
headers.append('Content-Type', 'application/json');

save.onclick = () => {
	const data = {title: 'test', html_content: '<p>hh</p>', markdown_content: 'hh'}
	const i = save.getElementsByTagName('i')[0];
	i.classList.add('fa-spin');
	i.classList.add('fa-spinner');
	fetch('http://localhost:3000/save', {
		method: 'POST',
		headers,
		body: JSON.stringify(data)
	})
}

const showdown = require('showdown'),
	  converter = new showdown.Converter();
const SimpleMDE = require('simplemde');
const simplemde = new SimpleMDE({
	initialValue: '- ddddd',
	previewRender(plainText, valueTxt){
		setTimeout(() => {
			valueTxt.innerHTML = converter.makeHtml(plainText);
		}, 250);
		return 'loading...';
	}
});
